package com.example.demo.rocketmq;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.stereotype.Service;


@EnableBinding(Source.class)
@Service
public class SenderService {
    @Autowired
    private Source source;

    public void send(String msg) throws Exception {
        boolean flag =source.output().send(MessageBuilder.withPayload(msg).build());
        System.out.println("消息发送：" + flag);
    }
}
